package com.zhou.common.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

/**
 * ConfigProperties
 *
 * @author zhouxianfeng
 * @date 2021-5-17
 */
@Component(value = "configPropertiesFactory")
public class ConfigProperties {
    //应用或组件英文简称
    private String appshortname;

    @Autowired
    private Environment env;

    /**
     * 读取配置文件
     *
     * @return ConfigProperties
     */
    @Bean
    public ConfigProperties configProperties() {
        ConfigProperties properties = new ConfigProperties();
        appshortname = env.getProperty("app.config.appshortname");
        properties.setAppshortname(appshortname);
        return properties;
    }

    /**
     * 取得应用与组件简称
     *
     * @return String
     */
    public String getAppshortname() {
        return appshortname;
    }

    /**
     * 设置应用与组件简称
     *
     * @return String
     */
    public void setAppshortname(String appshortname) {
        this.appshortname = appshortname;
    }

}

